cbuffer cbLight
{
	float gDiffuseCull = 0.0f;
};

struct Light
{
	float3 pos;
	float3 dir;
	float4 ambient;
	float4 diffuse;
	float4 specular;
	float3 atten;
	float  spotPower;
	float  range;
};

struct Surface
{
	float3 pos;
	float3 normal;
	float4 diffuse;
	float4 specular;
};

float3 ParallelLight(Surface surface, Light light, float3 eyePos)
{
	float3 litColor = float3(0.0f, 0.0f, 0.0f);
	float3 toLight = -light.dir;
	
	// ambient
	litColor += surface.diffuse * light.ambient;
	
	float cosNormalLight = dot(toLight, surface.normal);
	if (cosNormalLight > gDiffuseCull)
	{
		// diffuse
		litColor += cosNormalLight * surface.diffuse * light.diffuse;
		
		// specular
		float specPower = max(surface.specular.a, 1.0f);
		float3 toReflect = reflect(light.dir, surface.normal);
		float3 toEye = normalize(eyePos - surface.pos);
		float cosReflectEye = dot(toReflect, toEye);
		float specFactor = pow(max(cosReflectEye, 0.0f), specPower);
		litColor += specFactor * surface.specular * light.specular;
	}
	
	return litColor;
}

	